﻿using AutoMapper;
using BestTrader.Cms.Models;
using BestTrader.Cms.RmmfSoftServices.Models;
using BestTrader.Cms.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace BestTrader.Cms.Admin.Profiles
{
    public class MapperProfiles : Profile
    {
        public MapperProfiles()
        {
            CreateMap<SysItemsDetail, ItemsDetailModel>();

            #region ManagerRole
            CreateMap<ManagerRoleAddOrModifyModel, ManagerRole>();
            #endregion

            #region Manager
            CreateMap<Manager, ManagerListModel>();

            CreateMap<Manager, ItemsDetailModel>()
                 .ForMember(dto => dto.ItemName, opt => opt.MapFrom(entity => entity.UserName))
                 .ForMember(dto => dto.ItemCode, opt => opt.MapFrom(entity => entity.Id))
                 .ForMember(dto => dto.ItemData, opt => opt.MapFrom(entity => entity.RealName));
            //复制用户银行卡到用户银行卡表
            CreateMap<Manager, ManagerModifyBankCardModel>()
                .ForMember(dto => dto.BankType, opt => opt.MapFrom(entity => entity.BankType))
                .ForMember(dto => dto.BankCard, opt => opt.MapFrom(entity => entity.BankCard))
                .ForMember(dto => dto.BankCity, opt => opt.MapFrom(entity => entity.BankCity))
                .ForMember(dto => dto.BankProvince, opt => opt.MapFrom(entity => entity.BankProvince))
                .ForMember(dto => dto.ManagerId, opt => opt.MapFrom(entity => entity.Id));

            CreateMap<ManagerModifyBankCardModel, ManagerBankCard>();

            CreateMap<ManagerAddOrModifyModel, Manager>();

            CreateMap<ManagerAgentRegisterModel, Manager>();
            CreateMap<ManagerTerminalRegisterModel, Manager>();

            CreateMap<ManagerModifyDataModel, Manager>();

            #region 风软
            // 代理注册转换为风软的实体处理类
            //      代理没有银行卡信息信息
            CreateMap<Manager, CustomerInput>()
                .ConvertUsing<AgentToRmmfCustomerResolver>();

            // 直客注册转换为风软的实体处理类
            //      直客注册没用有用户名和密码
            CreateMap<ManagerTerminalRegisterModel, CustomerInput>()
                .ConvertUsing<TerminalToRmmfCustomerResolver>();
            #endregion

            #endregion

            #region Menu
            CreateMap<MenuAddOrModifyModel, Menu>();

            #endregion

            #region TradeCommission

            CreateMap<TradeCommission, TradeCommissionListModel>();

            CreateMap<TradeCommissionAddOrModifyModel, TradeCommission>();
            
            #endregion

            #region ExchangeRate

            CreateMap<ExchangeRate, ExchangeRateListModel>();
            CreateMap<ExchangeRateAddOrModifyModel, ExchangeRate>();

            #endregion

            #region RebateExtract

            CreateMap<RebateExtract, RebateExtractListModel>();
            CreateMap<RebateExtractAddOrModifyModel, RebateExtract>();

            #endregion

            #region RebateRecord

            CreateMap<RebateRecord, RebateRecordExcelModel>()
                .ConvertUsing<RebateRecordExcelResolver>();

            #endregion

            #region ServiceCharge

            CreateMap<ServiceCharge, ServiceChargeListModel>();
            CreateMap<UserTradeModel, ServiceCharge>();

            #endregion

            #region UserCenter

            CreateMap<Manager, InCoinUserModel>();
            CreateMap<Manager, OutCoinUserModel>();

            CreateMap<OutCashModel, UCInOutCash>();
            CreateMap<InCashModel, UCInOutCash>();
            CreateMap<UCInOutCash, ConfirmInCashModel>();

            CreateMap<QRCodeModel, UCAlipayInCash>()
                    .ForMember(dto => dto.QRCode, opt => opt.MapFrom(entity => entity.qrcode))
                    .ForMember(dto => dto.State, opt => opt.MapFrom(entity => entity.state))
                    .ForMember(dto => dto.Order, opt => opt.MapFrom(entity => entity.order))
                    .ForMember(dto => dto.Data, opt => opt.MapFrom(entity => entity.data))
                    .ForMember(dto => dto.Money, opt => opt.MapFrom(entity => entity.money))
                    .ForMember(dto => dto.Times, opt => opt.MapFrom(entity => entity.times))
                    .ForMember(dto => dto.OrderStatus, opt => opt.MapFrom(entity => entity.orderstatus))
                    .ForMember(dto => dto.Text, opt => opt.MapFrom(entity => entity.text));

            #endregion
        }
    }
}
